//
//  XYEmoticonBtn.swift
//  WeiboSourceCode
//
//  Created by 周星宇 on 16/1/8.
//  Copyright © 2016年 cn.weibo. All rights reserved.
//

import UIKit

class XYEmoticonBtn: UIButton {
    
    var emoticon: XYEmoticon? {
        
        didSet{
            if emoticon!.type == "0" {
                let imageName = emoticon!.fullPath
                self.setImage(UIImage(named: imageName, inBundle: XYEmoticonTool.sharedEmoticonTool.emoticonBundle, compatibleWithTraitCollection: nil), forState: .Normal)
                self.setTitle(nil, forState: .Normal)
            }else {
                // 是emoji表情
                self.setTitle((emoticon!.code! as NSString).emoji(), forState: .Normal)
                self.setImage(nil, forState: .Normal)
            }

        }
    }
}
